package com.zsl.blog.api.controller;

import com.zsl.blog.api.service.LoginService;
import com.zsl.blog.api.vo.Result;
import com.zsl.blog.api.vo.params.LoginParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


/**
*@Description:登录接口
* @param null
*@Return:
*@Data:2022/11/18 22:30
*@Author:zhaosilong
*/
@RequestMapping
@RestController
@Api(tags = "登录")
public class LoginController {
    @Autowired(required = false)
    private LoginService loginService;


    @ApiOperation("登录")
    @RequestMapping(value = "login",method = RequestMethod.POST)
    public Result login(@RequestBody @Validated LoginParam param){
        return loginService.login(param);
    }

    @GetMapping("logout")
    @ApiOperation("登出")
    public Result logout(@RequestHeader("Authorization") String token){
        return loginService.logout(token);
    }
}
